// Code generated by go-swagger; DO NOT EDIT.

package act_notification_api_service

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"fmt"
	"io"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"

	"gitlab.ozon.dev/qa/classroom-4/act-device-api/test/http_clients/generated_client/models"
)

// ActNotificationAPIServiceSubscribeNotificationReader is a Reader for the ActNotificationAPIServiceSubscribeNotification structure.
type ActNotificationAPIServiceSubscribeNotificationReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ActNotificationAPIServiceSubscribeNotificationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewActNotificationAPIServiceSubscribeNotificationOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	default:
		result := NewActNotificationAPIServiceSubscribeNotificationDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}

// NewActNotificationAPIServiceSubscribeNotificationOK creates a ActNotificationAPIServiceSubscribeNotificationOK with default headers values
func NewActNotificationAPIServiceSubscribeNotificationOK() *ActNotificationAPIServiceSubscribeNotificationOK {
	return &ActNotificationAPIServiceSubscribeNotificationOK{}
}

/*
ActNotificationAPIServiceSubscribeNotificationOK describes a response with status code 200, with default header values.

A successful response.(streaming responses)
*/
type ActNotificationAPIServiceSubscribeNotificationOK struct {
	Payload *ActNotificationAPIServiceSubscribeNotificationOKBody
}

// IsSuccess returns true when this act notification Api service subscribe notification o k response has a 2xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this act notification Api service subscribe notification o k response has a 3xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this act notification Api service subscribe notification o k response has a 4xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this act notification Api service subscribe notification o k response has a 5xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationOK) IsServerError() bool {
	return false
}

// IsCode returns true when this act notification Api service subscribe notification o k response a status code equal to that given
func (o *ActNotificationAPIServiceSubscribeNotificationOK) IsCode(code int) bool {
	return code == 200
}

func (o *ActNotificationAPIServiceSubscribeNotificationOK) Error() string {
	return fmt.Sprintf("[GET /api/v1/notification/subscribe/{deviceId}][%d] actNotificationApiServiceSubscribeNotificationOK  %+v", 200, o.Payload)
}

func (o *ActNotificationAPIServiceSubscribeNotificationOK) String() string {
	return fmt.Sprintf("[GET /api/v1/notification/subscribe/{deviceId}][%d] actNotificationApiServiceSubscribeNotificationOK  %+v", 200, o.Payload)
}

func (o *ActNotificationAPIServiceSubscribeNotificationOK) GetPayload() *ActNotificationAPIServiceSubscribeNotificationOKBody {
	return o.Payload
}

func (o *ActNotificationAPIServiceSubscribeNotificationOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(ActNotificationAPIServiceSubscribeNotificationOKBody)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewActNotificationAPIServiceSubscribeNotificationDefault creates a ActNotificationAPIServiceSubscribeNotificationDefault with default headers values
func NewActNotificationAPIServiceSubscribeNotificationDefault(code int) *ActNotificationAPIServiceSubscribeNotificationDefault {
	return &ActNotificationAPIServiceSubscribeNotificationDefault{
		_statusCode: code,
	}
}

/*
ActNotificationAPIServiceSubscribeNotificationDefault describes a response with status code -1, with default header values.

An unexpected error response.
*/
type ActNotificationAPIServiceSubscribeNotificationDefault struct {
	_statusCode int

	Payload *models.GooglerpcStatus
}

// Code gets the status code for the act notification Api service subscribe notification default response
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) Code() int {
	return o._statusCode
}

// IsSuccess returns true when this act notification Api service subscribe notification default response has a 2xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) IsSuccess() bool {
	return o._statusCode/100 == 2
}

// IsRedirect returns true when this act notification Api service subscribe notification default response has a 3xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) IsRedirect() bool {
	return o._statusCode/100 == 3
}

// IsClientError returns true when this act notification Api service subscribe notification default response has a 4xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) IsClientError() bool {
	return o._statusCode/100 == 4
}

// IsServerError returns true when this act notification Api service subscribe notification default response has a 5xx status code
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) IsServerError() bool {
	return o._statusCode/100 == 5
}

// IsCode returns true when this act notification Api service subscribe notification default response a status code equal to that given
func (o *ActNotificationAPIServiceSubscribeNotificationDefault) IsCode(code int) bool {
	return o._statusCode == code
}

func (o *ActNotificationAPIServiceSubscribeNotificationDefault) Error() string {
	return fmt.Sprintf("[GET /api/v1/notification/subscribe/{deviceId}][%d] ActNotificationApiService_SubscribeNotification default  %+v", o._statusCode, o.Payload)
}

func (o *ActNotificationAPIServiceSubscribeNotificationDefault) String() string {
	return fmt.Sprintf("[GET /api/v1/notification/subscribe/{deviceId}][%d] ActNotificationApiService_SubscribeNotification default  %+v", o._statusCode, o.Payload)
}

func (o *ActNotificationAPIServiceSubscribeNotificationDefault) GetPayload() *models.GooglerpcStatus {
	return o.Payload
}

func (o *ActNotificationAPIServiceSubscribeNotificationDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(models.GooglerpcStatus)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

/*
ActNotificationAPIServiceSubscribeNotificationOKBody Stream result of v1UserNotification
swagger:model ActNotificationAPIServiceSubscribeNotificationOKBody
*/
type ActNotificationAPIServiceSubscribeNotificationOKBody struct {

	// error
	Error *models.GooglerpcStatus `json:"error,omitempty"`

	// result
	Result *models.V1UserNotification `json:"result,omitempty"`
}

// Validate validates this act notification API service subscribe notification o k body
func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateError(formats); err != nil {
		res = append(res, err)
	}

	if err := o.validateResult(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) validateError(formats strfmt.Registry) error {
	if swag.IsZero(o.Error) { // not required
		return nil
	}

	if o.Error != nil {
		if err := o.Error.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "error")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "error")
			}
			return err
		}
	}

	return nil
}

func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) validateResult(formats strfmt.Registry) error {
	if swag.IsZero(o.Result) { // not required
		return nil
	}

	if o.Result != nil {
		if err := o.Result.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "result")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "result")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this act notification API service subscribe notification o k body based on the context it is used
func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := o.contextValidateError(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := o.contextValidateResult(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) contextValidateError(ctx context.Context, formats strfmt.Registry) error {

	if o.Error != nil {
		if err := o.Error.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "error")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "error")
			}
			return err
		}
	}

	return nil
}

func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) contextValidateResult(ctx context.Context, formats strfmt.Registry) error {

	if o.Result != nil {
		if err := o.Result.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "result")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("actNotificationApiServiceSubscribeNotificationOK" + "." + "result")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *ActNotificationAPIServiceSubscribeNotificationOKBody) UnmarshalBinary(b []byte) error {
	var res ActNotificationAPIServiceSubscribeNotificationOKBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
